home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / private / _chgattr.c < prev    next >
C/C++ Source or Header  |  1993-06-18  |  2KB  |  73 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3.  
  4. #ifdef PDCDEBUG
  5. char *rcsid__chgattr = "$Header: C:\CURSES\private\RCS\_chgattr.c 2.1 1993/06/18 20:23:11 MH Rel MH $";
  6. #endif
  7.  
  8.  
  9.  
  10.  
  11. /*man-start*********************************************************************
  12.  
  13.   PDC_chg_attrs()    - Change attributes in a rectangle
  14.  
  15.   PDCurses Description:
  16.      This routine will change the attribute(s) from a starting (y,x)
  17.      position to an ending (y,x) position to the specified attribute.
  18.  
  19.   PDCurses Return Value:
  20.      This function returns OK on success and ERR on error.
  21.  
  22.   PDCurses Errors:
  23.      It is an error to call this function with a NULL window pointer.
  24.      It is also an error to pass rectangular coordinates that lay
  25.      outside of window.
  26.  
  27.   Portability:
  28.      PDCurses    int PDC_chg_attrs( WINDOW* w, chtype attr,
  29.                      int sy, int sx,
  30.                      int ey, int ex );
  31.  
  32. **man-end**********************************************************************/
  33.  
  34. int    PDC_chg_attrs(WINDOW *w, chtype attr, int sy, int sx, int ey, int ex)
  35. {
  36.     chtype    oldattr = w->_attrs;
  37.     int    c;
  38.     int    l;
  39.  
  40. #ifdef PDCDEBUG
  41.     if (trace_on) PDC_debug("PDC_chr_attrs() - called\n");
  42. #endif
  43.  
  44.     if (w == (WINDOW *)NULL)        return( ERR );
  45.     if (sy > w->_maxy)    return( ERR );
  46.     if (sx > w->_maxx)    return( ERR );
  47.     if (ey >= w->_maxy)    ey = w->_maxy - 1;
  48.     if (ex >= w->_maxx)    ex = w->_maxx - 1;
  49.  
  50.     wattrset(w, attr);
  51.     for (l = sy; l <= ey; l++)
  52.     {
  53.         for (c = sx; c <= ex; c++)
  54.             w->_y[l][c] = (w->_y[l][c] & A_CHARTEXT) | attr;
  55.  
  56.         if (w->_firstch[l] == _NO_CHANGE)
  57.         {
  58.             w->_firstch[l] = sx;
  59.             w->_lastch[l] = ex;
  60.         }
  61.         else
  62.         if (w->_firstch[l] != _NO_CHANGE)
  63.         {
  64.             if (sx < w->_firstch[l])
  65.                 w->_firstch[l] = sx;
  66.             if (ex > w->_lastch[l])
  67.                 w->_lastch[l] = ex;
  68.         }
  69.     }
  70.     w->_attrs = oldattr;
  71.     return( OK );
  72. }
  73.